<?php
 /**
 * 功能描述：	验证码
 * @datetime	2020-05-1
 * @version   	v1.0
 * @author   	ZHL
 * @copyrigh  	2020 ZHL 版权所有
 */

class C_CaptchaController extends Controller {

    function index(){
        exit('error');
    }

    /**
     * Notes:图片验证码生成
     * User: ZhuHaili
     * Date: 2022/6/27
     * Return: png
     */
    function img() {
        $width = Fun::input('w','100','d');
        $height = Fun::input('h','40','d');
        $lengthCode = Fun::input('l','4','d');
        $type = Fun::input('t','1','d');
        $imgName = Fun::input('n');

        $imgNameArr = array(
            'a_img_code',
            'w_img_code',
            'c_img_code',
        );

        $codeName = in_array($imgName, $imgNameArr) ? $imgName : end($imgNameArr);
        $strTxt = strRand($lengthCode, $type);
        $arr = array('imgcode'=>$strTxt,'times'=>time());
        SYS_SESSIONS_SET($codeName, $arr);
        $verify = new Captcha;
        $verify->imgcode($strTxt, $lengthCode, $width, $height);
    }

}